package com.xiaoxu.privatechat.entity.common;

import com.xiaoxu.privatechat.annotion.ValidateEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import java.time.LocalDate;

/**
 * @author xiaoxu
 * @description 前台用户实体类
 * @date 2023/2/13
 */
@Entity
@Table(name = "pc_account")
@EntityListeners(AuditingEntityListener.class)
public class Account extends BaseEntity{
    private static final long serialVersionUID = 1L;
    /**
     * 性别男
     */
    public static final int USER_SEX_MAN = 1;
    /**
     * 性别女
     */
    public static final int USER_SEX_WOMAN = 0;
    /**
     * 用户状态正常可用
     */
    public static final int ACOUNT_USER_STATUS_ENABLE = 1;
    /**
     * 用户状态不可用
     */
    public static final int ACOUNT_USER_STATUS_UNABLE = 0;
    /**
     * 用户状态审核中
     */
    public static final int ACOUNT_USER_STATUS_EXAMINE = 2;
    /**
     * 用户在线
     */
    public static final String ACOUNT_CHAT_STATUS_ONLINE = "active";
    /**
     * 用户不在线
     */
    public static final String ACOUNT_CHAT_STATUS_OFFLINE = "status-offline";
    /**
     * 用户离开
     */
    public static final String ACOUNT_CHAT_STATUS_AWAY = "status-away";
    /**
     * 默认男生头像
     */
    public static final String ACOUNT_CHAT_HEAD_PIC_MAN = "default_man.png";
    /**
     * 默认女生头像
     */
    public static final String ACOUNT_CHAT_HEAD_PIC_WOMAN = "default_woman.png";

    /**
     * 用户名
     */
    @ValidateEntity(required = true, requiredLeng = true, minLength = 4, maxLength = 18, errorRequiredMsg = "用户名不能为空!", errorMinLengthMsg = "用户名长度需大于4!", errorMaxLengthMsg = "用户名长度不能大于18!")
    @Column(name = "username", nullable = false, length = 18, unique = true)
    private String username;
    /**
     * 登录密码
     */
    @ValidateEntity(required = true, requiredLeng = true, minLength = 4, maxLength = 32, errorRequiredMsg = "密码不能为空！", errorMinLengthMsg = "密码长度需大于4!", errorMaxLengthMsg = "密码长度不能大于32!")
    @Column(name = "password", nullable = false, length = 32)
    private String password;
    /**
     * 用户状态,默认审核中
     */
    @ValidateEntity()
    @Column(name = "status", length = 1)
    private int status;
    /**
     * 用户头像
     */
    @ValidateEntity()
    @Column(name = "head_pic", length = 128)
    private String headPic;
    /**
     * 用户性别 默认女
     */
    @ValidateEntity(required = true, errorRequiredMsg = "性别不能为空！")
    @Column(name = "sex", length = 1)
    private int sex;
    /**
     * 用户手机号
     */
    @ValidateEntity()
    @Column(name = "mobile", length = 12)
    private String mobile;
    /**
     * 用户邮箱
     */
    @ValidateEntity()
    @Column(name = "email", length = 32)
    private String email;
    /**
     * 用户简介
     */
    @ValidateEntity()
    @Column(name = "info", length = 128)
    private String info;
    /**
     * 用户简介
     */
    @ValidateEntity(required = true, errorRequiredMsg = "生日不能为空！")
    @Column(name = "birthday")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;
    /**
     * 用户聊天状态
     */
    @ValidateEntity()
    @Column(name = "chat_status", length = 18)
    private String chatStatus;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getHeadPic() {
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getChatStatus() {
        return chatStatus;
    }

    public void setChatStatus(String chatStatus) {
        this.chatStatus = chatStatus;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }


    @Override
    public String toString() {
        return "\n聊天室用户{" +
                "\n 用户名='" + username + '\'' +
                "\n 密码='" + password + '\'' +
                "\n 状态=" + status +
                "\n 头像='" + headPic + '\'' +
                "\n 性别=" + sex +
                "\n 手机号='" + mobile + '\'' +
                "\n 邮箱='" + email + '\'' +
                "\n 个性签名='" + info + '\'' +
                "\n 出生日期=" + birthday +
                "\n 在线状态='" + chatStatus + '\'' +
                "\n }";
    }
}
